package com.hz.house.controller;

import com.alibaba.fastjson.JSON;
import com.hz.house.common.ResultBean;
import com.hz.house.common.ResultUtil;
import com.hz.house.common.wxmini.WxMaSubscribeMessage;
import com.hz.house.service.WxMaSubscribeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 微信订阅消息接口
 * @author hello-world
 */
@RestController
@Api("订阅消息接口")
@RequestMapping("/wx/miniprogram/subscribe")
public class WxMaSubscribeController {

    @Resource
    private WxMaSubscribeService wxMaSubscribeService;

    @ApiOperation("获取订阅消息")
    @GetMapping("getTemplateList")
    public ResultBean getTemplateList(){
        return ResultUtil.ok(wxMaSubscribeService.getTemplateList());
    }

    @PostMapping("sendSubscribeMsg")
    @ApiOperation("发送订阅消息")
    public ResultBean sendSubscribeMsg(@RequestBody WxMaSubscribeMessage wxMaSubscribeMessage){
        System.out.println("发送模板消息:" + JSON.toJSONString(wxMaSubscribeMessage));
        wxMaSubscribeService.sendSubscribeMsg(wxMaSubscribeMessage);
        return ResultUtil.ok();
    }


}
